package com.itheima.kuozhan;

import java.lang.annotation.Annotation;
/*
获取一个类上的注解
判断注解是否是指定的注解
 */
public class Test {


    public static void main(String[] args) throws ClassNotFoundException {
        Class clazz = Class.forName("com.itheima.kuozhan.Demo");
        //获取所有的注解
        Annotation[] annotations = clazz.getAnnotations();
        for (Annotation annotation : annotations) {
            System.out.println(annotation);

        }
        //获取指定的注解
        Deprecated annotation = (Deprecated) clazz.getAnnotation(Deprecated.class);
        if (annotation!=null){
            System.out.println("这是一个过时的类");
        }

        //判断类上是否有指定的注解
        boolean flag = clazz.isAnnotationPresent(Deprecated.class);
        System.out.println(flag);

    }
}
